{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python3",
   "display_name": "DataAnalysis"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "source": [
    "# Chap2 获取文本语料库 和 词汇资源\n",
    "\n",
    "目的：\n",
    "\n",
    "1.  什么是有用的文本语料库和词汇资源？如何使用 Python 获取它们？\n",
    "2.  哪些 Python 结构最适合这项工作？\n",
    "3.  编写 Python 代码时如何避免重复的工作？"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "source": [
    "## 2.3 Python 中的 代码重用"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "source": [
    "### 2.3.1 使用文本编辑器创建Python程序\n",
    "建议使用IDE：VSCode 或者 PyCharm"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "source": [
    "### 2.3.2 如何定义函数\n",
    "\n",
    "-   Python 2 导入精确除法的代码：`from __future__ import division`\n",
    "-   现在默认使用 Python 3，默认精确除法；使用截断除法代码：`3//4`"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "source": [
    "### 2.3.3 Python 模块"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "plural('wish')=  wishes\nplural('fan')=  fen\n"
     ]
    }
   ],
   "source": [
    "# 修改 func 中的代码时，需要重启 Python Console 环境\n",
    "from func import plural\n",
    "\n",
    "print(\"plural('wish')= \", plural('wish'))\n",
    "print(\"plural('fan')= \", plural('fan'))"
   ]
  }
 ]
}